<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    img{
        position: absolute;
    }
</style>
<body>
    <img src="./images/angel.gif" alt="">
    <script>
        window.onload=function(){       //页面加载后可以获取图片宽高
            let img =document.querySelector('img');
            console.log(img.height);
            document.addEventListener('mousemove',function(e){
                let x=e.pageX-(img.width)/2 ;
                let y=e.pageY-(img.height)/2;
                img.style.left=x+'px';
                img.style.top=y+'px';
            })
        }
    </script>
</body>
</html>